﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HZ.Supervise.IBLL;
using HZ.Supervise.Model;
using HZ.Supervise.Model.Enum;
using HZ.Supervise.Model.View;

namespace HZ.Supervise.Web.Secondphase.Statistics
{ 
    public partial class CompanyResponse24HourByDetail : BasePage
    {
        
        IExecuteContext iec = HZ.Supervise.BLLFactory.ExecuteContext();

        public CompanyResponse24HourByDetail()
        {

        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
            }
        }

        protected void AspNetPager_CompanyPS_PageChanged(object sender, EventArgs e)
        { 
            BindData();

        }

        /// <summary>
        /// 绑定数据
        /// modify  by张雄  2011.5.4
        /// </summary>
        public void BindData()
        {
            SuperviseQuery vs = new SuperviseQuery();
            vs = Queryby();
            HZ.Supervise.Model.View.ProcureCatalog mPro = new HZ.Supervise.Model.View.ProcureCatalog();
            mPro = iec.GetProcureCatalogByID(vs.ProcureCatalogID);

            lblTitle.Text = string.Format(@"流水号：{3}； 通用名：{0}； 剂型：{1}； 包装：{2}； 生产企业：{4}； 配送企业：{5}；", mPro.ProductName, mPro.MedicineModelName, mPro.Pack, mPro.ProcureCatalogID, mPro.CompanyName_SC, vs.CompanyName_PS);
            int t = 0;
            System.Data.DataTable dt = iec.Get24HourByPurchase(vs, this.AspNetPager_CompanyPS.CurrentPageIndex, AspNetPager_CompanyPS.PageSize, out t);
            AspNetPager_CompanyPS.RecordCount = t;

            this.gvwPSLInfo.PageSize = AspNetPager_CompanyPS.PageSize;
            this.gvwPSLInfo.DataSource = dt;
            this.gvwPSLInfo.DataBind();



        }
        protected void btnQuery_Click(object sender, EventArgs e)
        {
            AspNetPager_CompanyPS.CurrentPageIndex = 1;
        }
         

        /// <summary>
        /// 导出 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnExcel_Click(object sender, EventArgs e)
        {
            SuperviseQuery vs = new SuperviseQuery();
            vs = Queryby();
            int t = 0;
            System.Data.DataTable dt = iec.Get24HourByPurchase(vs, 1, 0, out t);
            ExportFile.Instance.ExportData(dt, gvwPSLInfo, this.Page);
        }



        /// <summary>
        /// 查询条件
        /// </summary>
        /// <returns></returns>
        private SuperviseQuery Queryby()
        {
            SuperviseQuery vs = new SuperviseQuery(); 
            vs = (SuperviseQuery)Session[Request.QueryString["sesid"]];
            vs.OrderName = txtOrderName.Text.Trim();
            vs.HospitalName = txtHospitalName.Text.Trim();
            vs.SortFields = ddlSortFields.SelectedValue + " " + ddlSort.SelectedValue;

            return vs;
        }

        protected void btnBack_Click(object sender, EventArgs e)
        {
            string url = "CompanyResponse24HourByCompany.aspx?sesid=" + Request.QueryString["sesid"]; 
            Response.Redirect(url);
        }
    }
}
